<template>
  <div>
    <div class="page-title-wrapper">
      <div class="page-title">
        <h3>设计值配置</h3>
      </div>
      <div>
        <Button @click="handleBackClick">返回</Button>
      </div>
    </div>
    <!-- style="height:100%;position:relative" -->
    <section>
      <tHeader
        :h1="theaderObj.h1"
        :h2="theaderObj.h2"
        :htdpart="theaderObj.htdpart"
        :qqzhNumber="theaderObj.qqzhNumber"
      />
      <div>
        <iframe
          :src="src"
          frameborder="0"
          id="iframe"
          scrolling="no"
          name='report'
          @load="loadFrame"
          style="border:none;width:100%;height:612px"
        ></iframe>
      </div>
    </section>
  </div>
</template>

<script>
import tHeader from '../../../common_components/table-header-design';
import { tableRequestHeader } from '@/api/manage-design-value.js';
import { ProPrefix } from '@/config/cfg.js';

export default {
  components: {
    tHeader
  },
  data () {
    return {
      filename: '',
      src: '',
      nodeId: '',
      theaderObj: {
        h1: '',
        h2: '',
        htdpart: '',
        qqzhNumber: ''
      }
    };
  },
  mounted () {
    this.loadReportList();
  },
  methods: {
    loadFrame () {
    },
    handleBackClick () {
      this.$router.go(-1);
    },

    // 加载报表
    async loadReportList () {
      try {
        const param = this.$route.query;
        const resp = await tableRequestHeader({
          'nodeId': param.nodeId,
          'reportId': param.reportId
        });
        let respData = resp.data;
        if (respData.code != 200) {
          this.$Message.error(respData.msg);
          return;
        }
        console.log('respData=', respData);
        const { reportName, projectName, htdid, htdName, qqzh,
          token, filename, nodeId, url } = respData.data;

        this.theaderObj.h1 = reportName;
        this.theaderObj.h2 = projectName;
        this.theaderObj.htdpart = htdName;
        this.theaderObj.qqzhNumber = qqzh || '-';
        let url1Array = ['hu_tong_view', 'jian_kong_qi_view', 'kong_zhi_dian_view', 'pei_he_bi_view',
          'yuan_cai_liao_view', 'zhuangji_shejizhi_view', 'zuan_ji_view', 'weather_record_view'];
        let url2Array = ['zhuangji_shejizhi_input'];
        if (url1Array.includes(filename)) {
          this.src = `${ProPrefix + url}showInput.jsp?sht=/update/${filename}.sht&token=${token}&htdid=${htdid}`;
        } else if (url2Array.includes(filename)) {
          this.src = `${ProPrefix + url}showInput.jsp?sht=/update/${filename}.sht&token=${token}&htdid=${htdid}&nodeId=${nodeId}`;
        } else {
          // 设计表目前不涉及次类型，2022/11/21，zhanghaowei

          // arg1 = 当前表的此条数据id
          // pid = 当前工序id
          // tid = 默认1
          // nodeId = 部位id
          // htdid = 合同段id
          // sp_state = 当前表审批状态
          this.src = `${ProPrefix + url}showInput.jsp?sht=/update/${filename}.sht&arg1=47&pid=1560&token=${token}&tid=1&nodeId=${nodeId}&htdid=${htdId}&sp_state=deleted`;
        }

        console.log(this.src);
      } catch (error) {
        console.error(error);
      }
    }
  }
};
</script>

<style lang="less" scoped>
.main .content-wrapper {
  overflow-x: hidden;
}
.page-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-content: center;
  margin-bottom: 20px;
  .ivu-btn {
    margin-left: 20px;
  }
}
.borderRight{
  display:none;
}
</style>
